const scaleNames = {
  Celsius: (fahrenheit) => {
    return (fahrenheit - 32) * 5 / 9;
  },
  Fahrenheit: (celsius) => {
    return (celsius * 9 / 5) + 32;
  }
};

export function tryConvert(temperature, convert) {
    const input = parseFloat(temperature);
    if (isNaN(input)) {
        return '';
    }
    const output = scaleNames[convert](temperature);
    const rounded = Math.round(output * 1000) / 1000;
    return rounded.toString();
}
